package io.renren.modules.user.service.impl;


import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.segments.MergeSegments;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.common.utils.R;
import io.renren.modules.combat.entity.TFightInformationEntity;
import io.renren.modules.generator.dao.TTrainingDao;
import io.renren.modules.generator.entity.TTrainingEntity;
import io.renren.modules.statistis.statistisEntity;
import io.renren.modules.user.dao.TPeopleCopyDao;
import io.renren.modules.user.dao.TPeopleDao;
import io.renren.modules.user.dao.TPeopleResumeDao;
import io.renren.modules.user.entity.*;
import io.renren.modules.user.entity.vo.PeopleCountVo;
import io.renren.modules.user.entity.vo.PeopleHistoryVo;
import io.renren.modules.user.entity.vo.PeopleVo;
import io.renren.modules.user.entity.vo.PeopleZZVo;
import io.renren.modules.user.service.TPeopleCopyService;
import io.renren.modules.user.service.TPeopleLogService;
import io.renren.modules.user.service.TPeopleOutService;
import io.renren.modules.user.service.TPeopleService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;




@Service("tPeopleService")
public class TPeopleServiceImpl extends ServiceImpl<TPeopleDao, TPeopleEntity> implements TPeopleService {

    @Autowired
    private TPeopleDao tPeopleDao;
    @Autowired
    private TPeopleResumeDao tPeopleResumeDao;
    @Autowired
    private TPeopleCopyService tPeopleCopyService;
    @Autowired
    private TPeopleLogService tPeopleLogService;
    @Autowired
    private TPeopleOutService tPeopleOutService;
    @Autowired
    private TPeopleCopyDao tPeopleCopyDao;
    @Autowired
    private TTrainingDao trainingDao;



    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<TPeopleEntity> page = this.page(
                new Query<TPeopleEntity>().getPage(params),
                new QueryWrapper<TPeopleEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public List<PeopleVo> findPeopleList(String parentId,String squadron) {
        List<PeopleVo> peopleList = tPeopleDao.findPeopleList(parentId,squadron);
        return peopleList;
    }

    @Override
    public List<PeopleZZVo> findPeopleZZList(String parentId, String squadron) {
        List<PeopleZZVo> peopleZZList = tPeopleDao.findPeopleZZList(parentId,squadron);
        return peopleZZList;
    }

    @Override
    public List<PeopleVo> findPeopleClassesList(Integer deptId) {
        List<PeopleVo> peopleClassesList = tPeopleDao.findPeopleClassesList(deptId);
        return peopleClassesList;
    }

    @Override
    public List<PeopleZZVo> findPeopleClassesZZList(Integer deptId) {
        List<PeopleZZVo> peopleClassesZZList = tPeopleDao.findPeopleClassesZZList(deptId);
        return peopleClassesZZList;
    }

    @Override
    public PageUtils queryPageList(Map<String, Object> params) {
        IPage<TPeopleEntity> page = new Query<TPeopleEntity>().getPage(params);
       /* String deptd = (String)params.get("deptId");
        String pid =(String) params.get("id");
        String name =(String) params.get("name");
        String title =(String) params.get("title");
        String contractType =(String) params.get("contractType");
      //  Integer deptId=null;
        Integer id=null;
        if (pid == null || "".equals(pid)){
            id=null;
        }else {
            id= Integer.parseInt(pid);
        }*/
        List<TPeopleEntity> tPeopleEntities = tPeopleDao.queryPageList(params);
        page.setRecords(tPeopleEntities);
        return new PageUtils(page);
    }

    @Override
    public List<PeopleHistoryVo> peopleHistory(Integer peopleType,String deptId,String year,String squadron) {
        List<PeopleHistoryVo> peopleHistoryVos = tPeopleDao.peopleHistory(peopleType,deptId,year,squadron);
        return peopleHistoryVos;
    }

    @Override
    public List<PeopleHistoryVo> peopleHistoryDept(Integer peopleType,String deptId,String year,String zdeptId) {
        List<PeopleHistoryVo> peopleHistoryVos = tPeopleDao.peopleHistoryDept(peopleType,deptId,year,zdeptId);
        return peopleHistoryVos;
    }

    @Override
    public List<PeopleHistoryVo> peopleHistoryClasses(Integer peopleType,String deptId,String year) {
        List<PeopleHistoryVo> peopleHistoryVos = tPeopleDao.peopleHistoryClasses(peopleType,deptId,year);
        return peopleHistoryVos;
    }
    @Override
    public TPeopleEntity findPeople(Integer peopleId) {

        List<TPeopleEntity> tPeopleEntities = tPeopleDao.queryPageList1(peopleId);
        TPeopleEntity tPeopleEntity = tPeopleEntities.get(0);
        return tPeopleEntity;
    }

    @Override
    public List<TPeopleResumeEntity> findPeopleResume(Integer peopleId) {
        List<TPeopleResumeEntity> peopleResumeList = tPeopleResumeDao.findPeopleResume(peopleId);
        return peopleResumeList;
    }

    @Override
    public List<TFightInformationEntity> findFight(Integer peopleId) {
        List<TFightInformationEntity> fightList = tPeopleResumeDao.findFight(peopleId);
        return fightList;
    }

    @Override
    public List<TPeopleEntity> peopleCount() {
        List<TPeopleEntity> tPeopleEntities = tPeopleDao.peopleCount();
        return tPeopleEntities;
    }

    @Override
    public List<TPeopleFireDetachmentEntity> peopleDeptCount() {
        List<TPeopleFireDetachmentEntity> tPeopleFireDetachmentEntities = tPeopleDao.peopleDeptCount();
        return tPeopleFireDetachmentEntities;
    }

    @Override
    public List<TPeopleDictionaryEntity> peopelTitleCount() {
        List<TPeopleDictionaryEntity> tPeopleDictionaryEntities = tPeopleDao.peopelTitleCount();
        return tPeopleDictionaryEntities;
    }

    @Override
    public List<PeopleZZVo> peopleContractCount() {
        List<PeopleZZVo> peopleZZVos = tPeopleDao.peopleContractCount();
        return peopleZZVos;
    }

    @Override
    public List<TPeopleEntity> peopelStatistics(String deptId) {
      List<TPeopleEntity> peopleList = tPeopleDao.findPeopleSexList(deptId);
        return peopleList;
    }

    @Override
    public R peoplApply(TPeopleEntity people) {
        if ("0".equals(people.getFlag())) {
            List<TPeopleEntity> tPeopleEntityList = this.list(new QueryWrapper<TPeopleEntity>().
                    eq("id", people.getId())
            );
            List<TPeopleCopyEntity> tPeopleCoptList =tPeopleCopyService .list(new QueryWrapper<TPeopleCopyEntity>().
                    eq("id", people.getId())
            );
            TPeopleEntity tPeopleEntity = tPeopleEntityList.get(0);
            TPeopleCopyEntity tPeople=tPeopleCoptList.get(0);
            tPeopleCopyDao.updateByPrimaryKeySelective(tPeople);
            TPeopleLogEntity tPeopleLogEntity=new TPeopleLogEntity();
            if(null !=tPeople.getDept() && !tPeopleEntity.getDept().equals(tPeople.getDept())){
                tPeopleLogEntity.setFirstChanage("单位"+tPeopleEntity.getDept());
                tPeopleLogEntity.setEndChanage("单位"+tPeople.getDept());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            }
            if(null !=tPeopleEntity.getClasses() &&!tPeopleEntity.getClasses().equals(tPeople.getClasses())) {
                tPeopleLogEntity.setFirstChanage("班组"+tPeopleEntity.getClasses());
                tPeopleLogEntity.setEndChanage("班组"+tPeople.getClasses());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            }if(null !=tPeopleEntity.getName() &&!tPeopleEntity.getName().equals(tPeople.getName())) {
                tPeopleLogEntity.setFirstChanage("姓名"+tPeopleEntity.getName());
                tPeopleLogEntity.setEndChanage("姓名"+tPeople.getName());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeopleEntity.getName() &&!tPeopleEntity.getOldName().equals(tPeople.getOldName())) {
                tPeopleLogEntity.setFirstChanage("曾用命"+tPeopleEntity.getOldName());
                tPeopleLogEntity.setEndChanage("曾用命"+tPeople.getOldName());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getSex() && !tPeopleEntity.getSex().equals(tPeople.getSex())) {
                tPeopleLogEntity.setFirstChanage("性别"+tPeopleEntity.getSex());
                tPeopleLogEntity.setEndChanage("性别"+tPeople.getSex());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getEthnic() &&!tPeopleEntity.getEthnic().equals(tPeople.getEthnic())) {
                tPeopleLogEntity.setFirstChanage("民族"+tPeopleEntity.getEthnic());
                tPeopleLogEntity.setEndChanage("民族"+tPeople.getEthnic());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getBirthday() &&!tPeopleEntity.getBirthday().equals(tPeople.getBirthday())) {
                tPeopleLogEntity.setFirstChanage("生日"+tPeopleEntity.getBirthday());
                tPeopleLogEntity.setEndChanage("生日"+tPeople.getBirthday());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getBround() &&!tPeopleEntity.getBround().equals(tPeople.getBround())) {
                tPeopleLogEntity.setFirstChanage("籍贯"+tPeopleEntity.getBround());
                tPeopleLogEntity.setEndChanage("籍贯"+tPeople.getBround());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getIdcard() &&!tPeopleEntity.getIdcard().equals(tPeople.getIdcard())) {
                tPeopleLogEntity.setFirstChanage("身份证"+tPeopleEntity.getIdcard());
                tPeopleLogEntity.setEndChanage("身份证"+tPeople.getIdcard());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getWorkidcard() &&!tPeopleEntity.getWorkidcard().equals(tPeople.getWorkidcard())) {
                tPeopleLogEntity.setFirstChanage("工作证"+tPeopleEntity.getWorkidcard());
                tPeopleLogEntity.setEndChanage("工作证"+tPeople.getWorkidcard());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getDutytime() &&!tPeopleEntity.getDutytime().equals(tPeople.getDutytime())) {
                tPeopleLogEntity.setFirstChanage("入职时间"+tPeopleEntity.getDutytime());
                tPeopleLogEntity.setEndChanage("入职时间"+tPeople.getDutytime());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getTitleType() &&!tPeopleEntity.getTitleType().equals(tPeople.getTitleType())) {
                tPeopleLogEntity.setFirstChanage("衔级类别"+tPeopleEntity.getTitleType());
                tPeopleLogEntity.setEndChanage("衔级类别"+tPeople.getTitleType());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getTitle() &&!tPeopleEntity.getTitle().equals(tPeople.getTitle())) {
                tPeopleLogEntity.setFirstChanage("衔级"+tPeopleEntity.getTitle());
                tPeopleLogEntity.setEndChanage("衔级"+tPeople.getTitle());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getTitleTime() &&!tPeopleEntity.getTitleTime().equals(tPeople.getTitleTime())) {
                tPeopleLogEntity.setFirstChanage("当前衔级时间"+tPeopleEntity.getTitleTime());
                tPeopleLogEntity.setEndChanage("当前衔级时间"+tPeople.getTitleTime());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getDutyPost() &&!tPeopleEntity.getDutyPost().equals(tPeople.getDutyPost())) {
                tPeopleLogEntity.setFirstChanage("专业岗位"+tPeopleEntity.getDutyPost());
                tPeopleLogEntity.setEndChanage("专业岗位"+tPeople.getDutyPost());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getDutyPostTime() &&!tPeopleEntity.getDutyPostTime().equals(tPeople.getDutyPostTime())) {
                tPeopleLogEntity.setFirstChanage("当前岗位时间"+tPeopleEntity.getDutyPostTime());
                tPeopleLogEntity.setEndChanage("当前岗位时间"+tPeople.getDutyPostTime());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getFirePost() &&!tPeopleEntity.getFirePost().equals(tPeople.getFirePost())) {
                tPeopleLogEntity.setFirstChanage("消防职务"+tPeopleEntity.getFirePost());
                tPeopleLogEntity.setEndChanage("消防职务"+tPeople.getFirePost());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getFirePostTime() &&!tPeopleEntity.getFirePostTime().equals(tPeople.getFirePostTime())) {
                tPeopleLogEntity.setFirstChanage("消防职务任职时间"+tPeopleEntity.getFirePostTime());
                tPeopleLogEntity.setEndChanage("消防职务任职时间"+tPeople.getFirePostTime());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getFirePostClass() &&!tPeopleEntity.getFirePostClass().equals(tPeople.getFirePostClass())) {
                tPeopleLogEntity.setFirstChanage("职务等级"+tPeopleEntity.getFirePostClass());
                tPeopleLogEntity.setEndChanage("职务等级"+tPeople.getFirePostClass());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            }
            if(null!=tPeople.getFireClassTime()&&!tPeopleEntity.getFireClassTime().equals(tPeople.getFireClassTime())) {
                tPeopleLogEntity.setFirstChanage("职务年月"+tPeopleEntity.getFireClassTime());
                tPeopleLogEntity.setEndChanage("职务年月"+tPeople.getFireClassTime());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            }
            if(null !=tPeople.getTecPost() &&!tPeopleEntity.getTecPost().equals(tPeople.getTecPost())) {
                tPeopleLogEntity.setFirstChanage("技术职务"+tPeopleEntity.getTecPost());
                tPeopleLogEntity.setEndChanage("技术职务"+tPeople.getTecPost());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getTecPostTime() &&!tPeopleEntity.getTecPostTime().equals(tPeople.getTecPostTime())) {
                tPeopleLogEntity.setFirstChanage("技术职务时间"+tPeopleEntity.getTecPostTime());
                tPeopleLogEntity.setEndChanage("技术职务时间"+tPeople.getTecPostTime());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getTecClass() &&!tPeopleEntity.getTecClass().equals(tPeople.getTecClass())) {
                tPeopleLogEntity.setFirstChanage("技术等级"+tPeopleEntity.getTecClass());
                tPeopleLogEntity.setEndChanage("技术等级"+tPeople.getTecClass());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getTecClassTime() &&!tPeopleEntity.getTecClassTime().equals(tPeople.getTecClassTime())) {
                tPeopleLogEntity.setFirstChanage("技术等级年月"+tPeopleEntity.getTecClassTime());
                tPeopleLogEntity.setEndChanage("技术等级年月"+tPeople.getTecClassTime());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getAdministration() &&!tPeopleEntity.getAdministration().equals(tPeople.getAdministration())) {
                tPeopleLogEntity.setFirstChanage("行政职务"+tPeopleEntity.getAdministration());
                tPeopleLogEntity.setEndChanage("行政职务"+tPeople.getAdministration());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getAdministrationTime() &&!tPeopleEntity.getAdministrationTime().equals(tPeople.getAdministrationTime())) {
                tPeopleLogEntity.setFirstChanage("行政职务时间"+tPeopleEntity.getAdministrationTime());
                tPeopleLogEntity.setEndChanage("行政职务时间"+tPeople.getAdministrationTime());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getHousehold() &&!tPeopleEntity.getHousehold().equals(tPeople.getHousehold())) {
                tPeopleLogEntity.setFirstChanage("户籍"+tPeopleEntity.getHousehold());
                tPeopleLogEntity.setEndChanage("户籍"+tPeople.getHousehold());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getRegisterType() &&!tPeopleEntity.getRegisterType().equals(tPeople.getRegisterType())) {
                tPeopleLogEntity.setFirstChanage("户口类型"+tPeopleEntity.getRegisterType());
                tPeopleLogEntity.setEndChanage("户口类型"+tPeople.getRegisterType());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getInvitationHousehold() &&!tPeopleEntity.getInvitationHousehold().equals(tPeople.getInvitationHousehold())) {
                tPeopleLogEntity.setFirstChanage("招录前户籍"+tPeopleEntity.getInvitationHousehold());
                tPeopleLogEntity.setEndChanage("招录前户籍"+tPeople.getInvitationHousehold());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getInvitationRegister() &&!tPeopleEntity.getInvitationRegister().equals(tPeople.getInvitationRegister())) {
                tPeopleLogEntity.setFirstChanage("招录前户籍类型"+tPeopleEntity.getInvitationRegister());
                tPeopleLogEntity.setEndChanage("招录前户籍类型"+tPeople.getInvitationRegister());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getInvitation() &&!tPeopleEntity.getInvitation().equals(tPeople.getInvitation())) {
                tPeopleLogEntity.setFirstChanage("招录地省"+tPeopleEntity.getInvitation());
                tPeopleLogEntity.setEndChanage("招录地省"+tPeople.getInvitation());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getInvitation2() &&!tPeopleEntity.getInvitation2().equals(tPeople.getInvitation2())) {
                tPeopleLogEntity.setFirstChanage("招录地市"+tPeopleEntity.getInvitation2());
                tPeopleLogEntity.setEndChanage("招录地市"+tPeople.getInvitation2());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getPolitical() &&!tPeopleEntity.getPolitical().equals(tPeople.getPolitical())) {
                tPeopleLogEntity.setFirstChanage("政治面貌"+tPeopleEntity.getPolitical());
                tPeopleLogEntity.setEndChanage("政治面貌"+tPeople.getPolitical());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getPoliTime() &&!tPeopleEntity.getPoliTime().equals(tPeople.getPoliTime())) {
                tPeopleLogEntity.setFirstChanage("入党时间"+tPeopleEntity.getPoliTime());
                tPeopleLogEntity.setEndChanage("入党时间"+tPeople.getPoliTime());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getEducation() &&!tPeopleEntity.getEducation().equals(tPeople.getEducation())) {
                tPeopleLogEntity.setFirstChanage("文化程度"+tPeopleEntity.getEducation());
                tPeopleLogEntity.setEndChanage("文化程度"+tPeople.getEducation());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getSchool() &&!tPeopleEntity.getSchool().equals(tPeople.getSchool())) {
                tPeopleLogEntity.setFirstChanage("毕业学校"+tPeopleEntity.getSchool());
                tPeopleLogEntity.setEndChanage("毕业学校"+tPeople.getSchool());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getMajor() &&!tPeopleEntity.getMajor().equals(tPeople.getMajor())) {
                tPeopleLogEntity.setFirstChanage("专业"+tPeopleEntity.getMajor());
                tPeopleLogEntity.setEndChanage("专业"+tPeople.getMajor());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getEducationTime() &&!tPeopleEntity.getEducationTime().equals(tPeople.getEducationTime())) {
                tPeopleLogEntity.setFirstChanage("毕业时间"+tPeopleEntity.getEducationTime());
                tPeopleLogEntity.setEndChanage("毕业时间"+tPeople.getEducationTime());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getSolo() &&!tPeopleEntity.getSolo().equals(tPeople.getSolo())) {
                tPeopleLogEntity.setFirstChanage("独生子女"+tPeopleEntity.getSolo());
                tPeopleLogEntity.setEndChanage("独生子女"+tPeople.getSolo());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getCadre() &&!tPeopleEntity.getCadre().equals(tPeople.getCadre())) {
                tPeopleLogEntity.setFirstChanage("干部子女"+tPeopleEntity.getCadre());
                tPeopleLogEntity.setEndChanage("干部子女"+tPeople.getCadre());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getHomeType() &&!tPeopleEntity.getHomeType().equals(tPeople.getHomeType())) {
                tPeopleLogEntity.setFirstChanage("家庭情况"+tPeopleEntity.getHomeType());
                tPeopleLogEntity.setEndChanage("家庭情况"+tPeople.getHomeType());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getFireIdcard() &&!tPeopleEntity.getFireIdcard().equals(tPeople.getFireIdcard())) {
                tPeopleLogEntity.setFirstChanage("消防员证"+tPeopleEntity.getFireIdcard());
                tPeopleLogEntity.setEndChanage("消防员证"+tPeople.getFireIdcard());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getBlood() &&!tPeopleEntity.getBlood().equals(tPeople.getBlood())) {
                tPeopleLogEntity.setFirstChanage("血型"+tPeopleEntity.getBlood());
                tPeopleLogEntity.setEndChanage("血型"+tPeople.getBlood());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getHight() &&!tPeopleEntity.getHight().equals(tPeople.getHight())) {
                tPeopleLogEntity.setFirstChanage("身高"+tPeopleEntity.getHight());
                tPeopleLogEntity.setEndChanage("身高"+tPeople.getHight());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getMarry() &&!tPeopleEntity.getMarry().equals(tPeople.getMarry())) {
                tPeopleLogEntity.setFirstChanage("婚姻状况"+tPeopleEntity.getMarry());
                tPeopleLogEntity.setEndChanage("婚姻状况"+tPeople.getMarry());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getMarryTime() &&!tPeopleEntity.getMarryTime().equals(tPeople.getMarryTime())) {
                tPeopleLogEntity.setFirstChanage("结婚时间"+tPeopleEntity.getMarryTime());
                tPeopleLogEntity.setEndChanage("结婚时间"+tPeople.getMarryTime());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getSpouse() &&!tPeopleEntity.getSpouse().equals(tPeople.getSpouse())) {
                tPeopleLogEntity.setFirstChanage("配偶户籍"+tPeopleEntity.getSpouse());
                tPeopleLogEntity.setEndChanage("配偶户籍"+tPeople.getSpouse());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getKids() &&!tPeopleEntity.getKids().equals(tPeople.getKids())) {
                tPeopleLogEntity.setFirstChanage("生育情况"+tPeopleEntity.getKids());
                tPeopleLogEntity.setEndChanage("生育情况"+tPeople.getKids());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getAddress() &&!tPeopleEntity.getAddress().equals(tPeople.getAddress())) {
                tPeopleLogEntity.setFirstChanage("地址"+tPeopleEntity.getAddress());
                tPeopleLogEntity.setEndChanage("地址"+tPeople.getAddress());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getSocialCard() &&!tPeopleEntity.getSocialCard().equals(tPeople.getSocialCard())) {
                tPeopleLogEntity.setFirstChanage("社保卡"+tPeopleEntity.getSocialCard());
                tPeopleLogEntity.setEndChanage("社保卡"+tPeople.getSocialCard());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getContractType() &&!tPeopleEntity.getContractType().equals(tPeople.getContractType())) {
                tPeopleLogEntity.setFirstChanage("合同期限"+tPeopleEntity.getContractType());
                tPeopleLogEntity.setEndChanage("合同期限"+tPeople.getContractType());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getSeniorityHistory() &&!tPeopleEntity.getSeniorityHistory().equals(tPeople.getSeniorityHistory())) {
                tPeopleLogEntity.setFirstChanage("入职前工龄"+tPeopleEntity.getSeniorityHistory());
                tPeopleLogEntity.setEndChanage("入职前工龄"+tPeople.getSeniorityHistory());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getSeniorityNow() &&!tPeopleEntity.getSeniorityNow().equals(tPeople.getSeniorityNow())) {
                tPeopleLogEntity.setFirstChanage("本单位工龄"+tPeopleEntity.getSeniorityNow());
                tPeopleLogEntity.setEndChanage("本单位工龄"+tPeople.getSeniorityNow());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getSeniorityTotal() &&!tPeopleEntity.getSeniorityTotal().equals(tPeople.getSeniorityTotal())) {
                tPeopleLogEntity.setFirstChanage("总工龄"+tPeopleEntity.getSeniorityTotal());
                tPeopleLogEntity.setEndChanage("总工龄"+tPeople.getSeniorityTotal());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getCallPhone() &&!tPeopleEntity.getCallPhone().equals(tPeople.getCallPhone())) {
                tPeopleLogEntity.setFirstChanage("手机"+tPeopleEntity.getCallPhone());
                tPeopleLogEntity.setEndChanage("手机"+tPeople.getCallPhone());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getFileNumber() &&!tPeopleEntity.getFileNumber().equals(tPeople.getFileNumber())) {
                tPeopleLogEntity.setFirstChanage("档案号码"+tPeopleEntity.getFileNumber());
                tPeopleLogEntity.setEndChanage("档案号码"+tPeople.getFileNumber());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getStrength() &&!tPeopleEntity.getStrength().equals(tPeople.getStrength())) {
                tPeopleLogEntity.setFirstChanage("特长"+tPeopleEntity.getStrength());
                tPeopleLogEntity.setEndChanage("特长"+tPeople.getStrength());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getInstructions() &&!tPeopleEntity.getInstructions().equals(tPeople.getInstructions())) {
                tPeopleLogEntity.setFirstChanage("说明"+tPeopleEntity.getInstructions());
                tPeopleLogEntity.setEndChanage("说明"+tPeople.getInstructions());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getPicture() &&!tPeopleEntity.getPicture().equals(tPeople.getPicture())) {
                tPeopleLogEntity.setFirstChanage("图片"+tPeopleEntity.getPicture());
                tPeopleLogEntity.setEndChanage("图片"+tPeople.getPicture());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getAccessories() &&!tPeopleEntity.getAccessories().equals(tPeople.getAccessories())) {
                tPeopleLogEntity.setFirstChanage("附件"+tPeopleEntity.getAccessories());
                tPeopleLogEntity.setEndChanage("附件"+tPeople.getAccessories());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getState() &&!tPeopleEntity.getState().equals(tPeople.getState())) {
                tPeopleLogEntity.setFirstChanage("状态"+tPeopleEntity.getState());
                tPeopleLogEntity.setEndChanage("状态"+tPeople.getState());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            } if(null !=tPeople.getEffective() &&!tPeopleEntity.getEffective().equals(tPeople.getEffective())) {
                tPeopleLogEntity.setFirstChanage("有效性"+tPeopleEntity.getEffective());
                tPeopleLogEntity.setEndChanage("有效性"+tPeople.getEffective());
                tPeopleLogEntity.setPeopleId(tPeople.getId());
                tPeopleLogEntity.setCreateUser(tPeople.getCreateUser());
                tPeopleLogEntity.setCreateTime(new Date());
                tPeopleLogService.save(tPeopleLogEntity);
            }

            return R.ok();
        } /*else {
            TPeopleCopyEntity tPeopleCopyEntity = new TPeopleCopyEntity();
            List<TPeopleCopyEntity> tPeopleCopyList = tPeopleCopyService.list(new QueryWrapper<TPeopleCopyEntity>()
                    .eq("id", tPeople.getId())
                    .orderByDesc("create_time")
            );
            //审批不通过
            tPeopleCopyEntity.setState("4");
            tPeopleCopyEntity.setCopyId(tPeopleCopyList.get(0).getCopyId());
            tPeopleCopyService.updateById(tPeopleCopyEntity);
            return R.ok();
        }*/
        return R.ok();
    }

    @Override
    public R updatePeopleOut(TPeopleOutEntity tPeopleOutEntity) {
        if(tPeopleOutEntity.getFlag()=="0"){ //通过
            //记录人员退出信息
            TPeopleOutEntity tPeopleOut=new TPeopleOutEntity();
            /*tPeopleOutEntity.setPeopleId(tPeopleOutEntity.getPeopleId());
            tPeopleOutEntity.setPeopleName(tPeopleOutEntity.getPeopleName());
            tPeopleOutEntity.setOutTime(new Date());
            tPeopleOutEntity.setOutType();*/
            tPeopleOutService.save(tPeopleOutEntity);
        }

        return null;
    }

    @Override
    public PeopleCountVo peopledeptCount(String deptId) {
        PeopleCountVo peopleCountVo = tPeopleDao.peopledeptCount(deptId);
        return peopleCountVo;
    }

    @Override
    public PeopleCountVo peopledeptCount1(String deptId) {
        PeopleCountVo peopleCountVo = tPeopleDao.peopledeptCount1(deptId);
        return peopleCountVo;
    }

    @Override
    public PeopleCountVo peopledeptCount2(String deptId, String classes) {
        PeopleCountVo peopleCountVo = tPeopleDao.peopledeptCount2(deptId, classes);
        return peopleCountVo;
    }


    @Override
    public List<PeopleVo> peopleListInfo(String deptId,String zdeptId) {
        List<PeopleVo> peopleVos = tPeopleDao.peopleListInfo(deptId,zdeptId);
        return peopleVos;
    }

    @Override
    public List<PeopleZZVo> findPeopleZList(String parentId,String zdeptId) {
        List<PeopleZZVo> peopleZList = tPeopleDao.findPeopleZList(parentId,zdeptId);
        return peopleZList;
    }

    @Override
    public List<TTrainingEntity> findPeopleTTraining(Integer peopleId) {
        TTrainingEntity tTrainingEntity=new TTrainingEntity();
        tTrainingEntity.setPersonId(peopleId);
        return trainingDao.findPeopleTTraining(tTrainingEntity);

    }

    /**
     * 总队数据
     */
   public List<PeopleVo> totalCount(statistisEntity peopleVo){
        return tPeopleDao.totalCount(peopleVo);
    }

    /*
     * 消防总队
     * */
   public PeopleVo findAllDept(){
       return tPeopleDao.findAllDept();
    }

    /*
     * 专职总队
     * */
    public PeopleZZVo findALLZZDept(statistisEntity peopleVo){
        return tPeopleDao.findALLZZDept(peopleVo);
    }

    /*
     * 历史总队
     * */
    public PeopleHistoryVo peopleAllHistory(statistisEntity peopleVo){
        return tPeopleDao.peopleAllHistory(peopleVo);
    }

    public TPeopleEntity getPeopleInfoByIdCard(String idcard){
        return tPeopleDao.getPeopleInfoByIdCard(idcard);
    }

}